package com.example.demo.config;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

//@Data //@Data注解在类上，会为类的所有属性自动生成setter/getter、equals、canEqual、hashCode、toString方法，如为final属性，则不会为该属性生成setter方法。@Value注解和@Data类似，区别在于它会把所有成员变量默认定义为private final修饰，并且不会生成set方法。
@Setter
@Getter

@Component
@Configuration
@PropertySource(value = "classpath:application.properties", encoding = "utf-8")
//@PropertySources(value = {@PropertySource("classpath:demo.properties"),@PropertySource("classpath:demoadd.properties")})
public class Student{
    @Value("${person.name}")
    private String name;
    private String age;

    public String getName() {
        //return name;
        //中文会乱码
         return new String(name.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
    }
}
